package com.hnust.dao;

import com.hnust.domain.record.RepeatQues;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 试卷&题目库的dao操作
 * @author 小游
 * @date 2020/10/30
 */
@Mapper
@Repository
public interface QuestionPaperDao {

    /**
     * 插入一条试卷题目对照记录
     * @param id 记录id
     * @param queId 试题id
     * @param papId 试卷id
     * @return 插入成功的条数
     */
    @Insert("insert into question_paper (que_pap_id,que_id,pap_id) values (#{id},#{queId},#{papId})")
    Integer insertQuestionRecord (String id,String queId,String papId);

    /**
     * 根据题目id和课程id来查找重复的题目
     * @param couId 课程id
     * @param questions 题目
     * @return 返回重复的内容
     */
    @Select("SELECT a.que_id,b.`name` AS paper_name from question_paper as a, paper as b,course as c WHERE a.pap_id = b.pap_id AND c.cou_number = b.cou_number AND c.cou_id = #{couId} AND a.que_id IN (${questions})")
    List<RepeatQues> checkRepeatQuestion (String couId, String questions);
}
